import { CHANGE_CID, CHANNEL_LIST } from '../constants/channels'

export default function channels (state = {
  currentId: '', // 当前 ID
  list: [] // 频道数据
}, action) {
  switch (action.type) {
    case CHANNEL_LIST:
      // 后端返回啥，存啥
      return {
        ...state,
        currentId: action.id,
        list: action.payload
      }
    case CHANGE_CID:
      return {
        ...state,
        currentId: action.cid
      }
    default:
      return state
  }
}